Page({
  data: {
    list: [],
    text: ""
  },
  async onLoad() {
    const res = await this.getList()

    this.setData({
      list: res.data
    })


  },
  getList() {
    const promise = new Promise(resolve => {
      wx.request({
        url: 'https://api-vue-base.itheima.net/api/lol/search',
        data: {
          q: this.data.text
        },
        success: (res) => {
          console.log(res.data);
          resolve(res.data)
        }
      })
    })
    return promise
  },
  // 搜索 点击完成|按下回车
  async onSearch() {
    // wx.showToast({
    //   title: this.data.text,
    // })
    const res = await this.getList()

    this.setData({
      list: res.data
    })
  }
})